<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        [v-cloak]{
            display: none;
        }
    </style>
</head>
<body>
    <div id="app">
        <input type="text" v-model='msg'>
        <div>{{msg | upper | lower}}</div>
        <div :abc='msg | upper'>测试</div>
        <!-- 带参数过滤器 -->
        <div v-cloak>{{date|dateFormat('yyyy-MM-dd')}}</div>
    </div>
    <script src="../node_modules/vue/dist/vue.min.js"></script>
    <script>

        // Vue.filter('upper',function(val){
        //     return val.charAt(0).toUpperCase()+val.slice(1);
        // })
        Vue.filter('lower', function (val) {
                return val.charAt(0).toLowerCase() + val.slice(1);
        })
        var vm = new Vue({
            el:'#app',
            data:{
                msg:'',
                date: new Date()
            },
            methods: {
                
            },
            // 局部过滤器
            filters:{
                upper:function(val){
                    return val.charAt(0).toUpperCase() + val.slice(1);
                },
                // 带参数的日期过滤器
                dateFormat:function(val,arg){
                    if(arg== 'yyyy-MM-dd'){
                        var ret ='';
                        ret +=val.getFullYear()+'-'+(val.getMonth()+1) + '-' + val.getDate();
                        return ret;
                    }
                    return 
                }
            }
        })
    </script>
</body>
</html>